﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class SanDiaOc : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadMenuNhaDatBan();
            LoadMenuNhaChoThue();
            LoadMenuCanThue();
            LoadMenuCanMua();
        }
    }

    private void LoadMenuNhaDatBan()
    {
        string sHtmlMenu = "";

        NhaDatMenuManager NhaDat = new NhaDatMenuManager();
        List<NhaDat> NhaDats = NhaDat.getAllNhaDatMenu();

        int i = 1;
        foreach (NhaDat aNhaDat in NhaDats)
        {
            if (NhaDats.Count == i)
            {
                sHtmlMenu += "<li class='otherLink'>";
            }
            else
            {
                sHtmlMenu += "<li>";
            }
            sHtmlMenu += "<a href=\"nha-dat-ban/index.html\" title=\"" + aNhaDat.Ten + "\">" + aNhaDat.Ten + " <span id=\"spBDS1_0_" + i++ + "\"></span></a></li>";
        }

        menuNhaDatBan.Text = sHtmlMenu;
    }

    private void LoadMenuNhaChoThue()
    {
        string sHtmlMenu = "";

        NhaChoThueMenuManager NhaChoThue = new NhaChoThueMenuManager();
        List<NhaChoThue> NhaChoThues = NhaChoThue.getAllNhaChoThueMenu();

        int i = 1;
        foreach (NhaChoThue aNhaCT in NhaChoThues)
        {
            if (NhaChoThues.Count == i)
            {
                sHtmlMenu += "<li class='otherLink'>";
            }
            else
            {
                sHtmlMenu += "<li>";
            }
            sHtmlMenu += "<a href=\"nha-dat-ban/index.html\" title=\"" + aNhaCT.Ten + "\">" + aNhaCT.Ten + " <span id=\"spBDS2_0_" + i++ + "\"></span></a></li>";
        }

        menuNhaChoThue.Text = sHtmlMenu;
    }

    private void LoadMenuCanThue()
    {
        string sHtmlMenu = "";

        CanThueMenuManager CanChoThue = new CanThueMenuManager();
        List<CanThue> canThues = CanChoThue.getAllCanThueMenu();

        int i = 1;
        foreach (CanThue aCanThue in canThues)
        {

            if (canThues.Count == i)
            {
                sHtmlMenu += "<li class='otherLink'>";
            }
            else
            {
                sHtmlMenu += "<li>";
            }
            sHtmlMenu += "<a href=\"nha-dat-ban/index.html\" title=\"" + aCanThue.Ten + "\">" + aCanThue.Ten + " <span id=\"spBDS2_0_" + i++ + "\"></span></a></li>";
        }

        menuCanThue.Text = sHtmlMenu;
    }

    private void LoadMenuCanMua()
    {
        string sHtmlMenu = "";

        CanMuaMenuManager CanMua = new CanMuaMenuManager();
        List<CanMua> canMuas = CanMua.getAllCanMuaMenu();

        int i = 1;
        foreach (CanMua aCanMua in canMuas)
        {
            if (canMuas.Count == i)
            {
                sHtmlMenu += "<li class='otherLink'>";
            }
            else
            {
                sHtmlMenu += "<li>";
            }
            sHtmlMenu += "<a href=\"nha-dat-ban/index.html\" title=\"" + aCanMua.Ten + "\">" + aCanMua.Ten + " <span id=\"spBDS2_0_" + i++ + "\"></span></a></li>";
        }

        menuCanMua.Text = sHtmlMenu;
    }

    protected void btnLogout_Click(object sender, EventArgs e)
    {
        Session.Remove("diaoconline_do_online");
        Response.Redirect("/");
    }
}
